/*****************************************************************************
 * plum_kal_timer.h
 *
 * Copyright (C) 2020 Jeasonvor <1101627719@qq.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/

#ifndef __PLUM_KAL_TIMER_H__
#define __PLUM_KAL_TIMER_H__
/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/
#define PLUM_KAL_TIMER_NAME_MAX 16
/*****************************************************************************
 * Public Types
 ****************************************************************************/

typedef enum {
    PLUM_KAL_TIMER_MODE_ONCE,     /* 单次 */
    PLUM_KAL_TIMER_MODE_PERIODIC, /* 周期 */
} plum_kal_timer_mode_t;

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/**
 * @brief:  创建定时器
 *
 * @param[in]:  name    -   定时器名称
 * @param[in]:  fn      -   定时器回调
 * @param[in]:  arg     -   定时器回调参数
 * @parma[in]:  period  -   定时周期
 * @param[in]:  mode    -   定时模式
 *
 * @return: 返回错误码
 */
plum_s32 plum_kal_timer_create(PLUM_CONST plum_s8 *name,
                               plum_void (*fn)(plum_void *arg), plum_void *arg,
                               plum_u32 period, plum_kal_timer_mode_t mode);

/**
 * @brief:  删除定时器
 *
 * @param[in]:  name  -   定时器名称
 *
 * @return: 返回错误码
 */
plum_s32 plum_kal_timer_delete(PLUM_CONST plum_s8 *name);

/**
 * @brief:  挂起定时器
 *
 * @param[in]:  name  -   定时器名称
 *
 * @return: 返回错误码
 */
plum_u32 plum_kal_timer_suspend(PLUM_CONST plum_s8 *name);

/**
 * @brief:  恢复定时器
 *
 * @param[in]:  name  -   定时器名称
 *
 * @return: 返回错误码
 */
plum_s32 plum_kal_timer_resume(PLUM_CONST plum_s8 *name);

/**
 * @brief:  展示定时器信息
 *
 * @param[in]:  name  -   定时器名称，如果为空，则表示所有
 *
 * @return:
 */
plum_void plum_kal_timer_show(PLUM_CONST plum_s8 *name);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_KAL_TIMER_H__ */
/****************************************************************************/

/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
